﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace SmartMeterParamSetting.UI
{
    /// <summary>
    /// SelectScheme.xaml 的交互逻辑
    /// </summary>
    public partial class SelectScheme : Window
    {

        /// <summary>
        /// 用户选择的方案
        /// </summary>
        public string SelectedScheme { get; set; }

        public SelectScheme()
        {
            InitializeComponent();
        }

        public SelectScheme(string[] schemes)
            : this()
        {
            Lst_Schemes.DataContext = schemes;
        }


        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Button btnSource = sender as Button;
            if (btnSource == null) return;
            if (btnSource.Name == btnOk.Name)
            {
                SelectDownLoadScheme();
                DialogResult = true;
            }
            else
            {
                DialogResult = false;                
            }
        }

        private void Lst_Schemes_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            SelectDownLoadScheme();
            DialogResult = true;
        }

        private void SelectDownLoadScheme()
        {
            if (Lst_Schemes.SelectedItem == null) return;
            SelectedScheme = Lst_Schemes.SelectedItem.ToString();
        }
    }
}
